package cn.cdutetc.library.controller;

import cn.cdutetc.library.service.ScheduledBackupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 备份测试控制器（用于测试定时备份功能）
 */
@RestController
@RequestMapping("/api/backup/test")
@CrossOrigin(originPatterns = "*")
public class BackupTestController {

    @Autowired
    private ScheduledBackupService scheduledBackupService;

    /**
     * 手动触发备份（用于测试）
     */
    @PostMapping("/manual-backup")
    public String manualBackup() {
        try {
            scheduledBackupService.manualBackup();
            return "手动备份任务已触发";
        } catch (Exception e) {
            return "手动备份任务失败: " + e.getMessage();
        }
    }
}
